move grab_focus to after handling the button presses in the TreeView to
authorJonathan Blandford <jrb@gnome.org>
Thu, 15 Jan 2004 00:12:23 +0000 (00:12 +0000)
committerJonathan Blandford <jrb@src.gnome.org>
Thu, 15 Jan 2004 00:12:23 +0000 (00:12 +0000)
Wed Jan 14 18:01:52 2004  Jonathan Blandford  <jrb@gnome.org>

        * gtk/gtktreeview.c (gtk_tree_view_button_press): move grab_focus
        to after handling the button presses in the TreeView to avoid
        getting multiple selection_changes()

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtktreeview.c

index 8b0a4efffebe3b283b32adbf6c902ce41244c63c..e2ee6040a8d36d859bed69adfccec0011244d3c8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Wed Jan 14 18:01:52 2004  Jonathan Blandford  <jrb@gnome.org>
+
+       * gtk/gtktreeview.c (gtk_tree_view_button_press): move grab_focus
+       to after handling the button presses in the TreeView to avoid
+       getting multiple selection_changes()
+
 Wed Jan 14 21:16:20 2004  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkimcontext.c: Documentation fix.  (#131335, Theppitak 
index 8b0a4efffebe3b283b32adbf6c902ce41244c63c..e2ee6040a8d36d859bed69adfccec0011244d3c8 100644 (file)
@@ -1,3 +1,9 @@
+Wed Jan 14 18:01:52 2004  Jonathan Blandford  <jrb@gnome.org>
+
+       * gtk/gtktreeview.c (gtk_tree_view_button_press): move grab_focus
+       to after handling the button presses in the TreeView to avoid
+       getting multiple selection_changes()
+
 Wed Jan 14 21:16:20 2004  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkimcontext.c: Documentation fix.  (#131335, Theppitak 
index 8b0a4efffebe3b283b32adbf6c902ce41244c63c..e2ee6040a8d36d859bed69adfccec0011244d3c8 100644 (file)
@@ -1,3 +1,9 @@
+Wed Jan 14 18:01:52 2004  Jonathan Blandford  <jrb@gnome.org>
+
+       * gtk/gtktreeview.c (gtk_tree_view_button_press): move grab_focus
+       to after handling the button presses in the TreeView to avoid
+       getting multiple selection_changes()
+
 Wed Jan 14 21:16:20 2004  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkimcontext.c: Documentation fix.  (#131335, Theppitak 
index 8b0a4efffebe3b283b32adbf6c902ce41244c63c..e2ee6040a8d36d859bed69adfccec0011244d3c8 100644 (file)
@@ -1,3 +1,9 @@
+Wed Jan 14 18:01:52 2004  Jonathan Blandford  <jrb@gnome.org>
+
+       * gtk/gtktreeview.c (gtk_tree_view_button_press): move grab_focus
+       to after handling the button presses in the TreeView to avoid
+       getting multiple selection_changes()
+
 Wed Jan 14 21:16:20 2004  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkimcontext.c: Documentation fix.  (#131335, Theppitak 
index 8b0a4efffebe3b283b32adbf6c902ce41244c63c..e2ee6040a8d36d859bed69adfccec0011244d3c8 100644 (file)
@@ -1,3 +1,9 @@
+Wed Jan 14 18:01:52 2004  Jonathan Blandford  <jrb@gnome.org>
+
+       * gtk/gtktreeview.c (gtk_tree_view_button_press): move grab_focus
+       to after handling the button presses in the TreeView to avoid
+       getting multiple selection_changes()
+
 Wed Jan 14 21:16:20 2004  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkimcontext.c: Documentation fix.  (#131335, Theppitak 
index 36bc851a55e7bcd923626884d8275d27fbb6ba68..07bfa0a039985c217575fd43216b8c624c00687f 100644 (file)
@@ -2013,16 +2013,13 @@ gtk_tree_view_button_press (GtkWidget      *widget,
                        "horizontal_separator", &horizontal_separator,
                        NULL);
 
-  /* put this separate, because the user might remove the latest
-   * treeview node in the focus-in-event callback. If so, the code
-   * flow won't enter the second if.
+
+  /* Because grab_focus can cause reentrancy, we delay grab_focus until after
+   * we're done handling the button press.
    */
   if (event->window == tree_view->priv->bin_window &&
       tree_view->priv->tree != NULL)
     {
-      if (!GTK_WIDGET_HAS_FOCUS (widget))
-       gtk_widget_grab_focus (widget);
-      GTK_TREE_VIEW_UNSET_FLAG (tree_view, GTK_TREE_VIEW_DRAW_KEYFOCUS);
     }
 
   if (event->window == tree_view->priv->bin_window &&
@@ -2059,6 +2056,9 @@ gtk_tree_view_button_press (GtkWidget      *widget,
                                        event->x,
                                        event->y);
            }
+         if (!GTK_WIDGET_HAS_FOCUS (widget))
+           gtk_widget_grab_focus (widget);
+         GTK_TREE_VIEW_UNSET_FLAG (tree_view, GTK_TREE_VIEW_DRAW_KEYFOCUS);
          return TRUE;
        }
 
@@ -2069,8 +2069,13 @@ gtk_tree_view_button_press (GtkWidget      *widget,
       y_offset = -_gtk_rbtree_find_offset (tree_view->priv->tree, new_y, &tree, &node);
 
       if (node == NULL)
-       /* We clicked in dead space */
-       return TRUE;
+       {
+         /* We clicked in dead space */
+         if (!GTK_WIDGET_HAS_FOCUS (widget))
+           gtk_widget_grab_focus (widget);
+         GTK_TREE_VIEW_UNSET_FLAG (tree_view, GTK_TREE_VIEW_DRAW_KEYFOCUS);
+         return TRUE;
+       }
 
       /* Get the path and the node */
       path = _gtk_tree_view_find_path (tree_view, tree, node);
@@ -2117,7 +2122,9 @@ gtk_tree_view_button_press (GtkWidget      *widget,
       if (column == NULL)
        {
          gtk_tree_path_free (path);
-
+         if (!GTK_WIDGET_HAS_FOCUS (widget))
+           gtk_widget_grab_focus (widget);
+         GTK_TREE_VIEW_UNSET_FLAG (tree_view, GTK_TREE_VIEW_DRAW_KEYFOCUS);
          return FALSE;
        }
 
@@ -2287,8 +2294,6 @@ gtk_tree_view_button_press (GtkWidget      *widget,
             }
         }
 
-      GTK_TREE_VIEW_UNSET_FLAG (tree_view, GTK_TREE_VIEW_DRAW_KEYFOCUS);
-
       if (row_double_click)
        {
          gtk_grab_remove (widget);
@@ -2300,6 +2305,10 @@ gtk_tree_view_button_press (GtkWidget      *widget,
 
       gtk_tree_path_free (path);
 
+      if (!GTK_WIDGET_HAS_FOCUS (widget))
+       gtk_widget_grab_focus (widget);
+      GTK_TREE_VIEW_UNSET_FLAG (tree_view, GTK_TREE_VIEW_DRAW_KEYFOCUS);
+
       return TRUE;
     }